package com.sa.banner.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sa.common.annotation.Log;
import com.sa.common.core.controller.BaseController;
import com.sa.common.core.domain.AjaxResult;
import com.sa.common.enums.BusinessType;
import com.sa.banner.domain.TInnovateBanner;
import com.sa.banner.service.ITInnovateBannerService;
import com.sa.common.utils.poi.ExcelUtil;
import com.sa.common.core.page.TableDataInfo;

/**
 * 创新链Controller
 * 
 * @author wcc
 * @date 2023-12-16
 */
@RestController
@RequestMapping("/banner/banner")
public class TInnovateBannerController extends BaseController
{
    @Autowired
    private ITInnovateBannerService tInnovateBannerService;

    /**
     * 查询创新链列表
     */
    @PreAuthorize("@ss.hasPermi('banner:banner:list')")
    @GetMapping("/list")
    public TableDataInfo list(TInnovateBanner tInnovateBanner)
    {
        startPage();
        List<TInnovateBanner> list = tInnovateBannerService.selectTInnovateBannerList(tInnovateBanner);
        return getDataTable(list);
    }

    /**
     * 导出创新链列表
     */
    @PreAuthorize("@ss.hasPermi('banner:banner:export')")
    @Log(title = "创新链", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TInnovateBanner tInnovateBanner)
    {
        List<TInnovateBanner> list = tInnovateBannerService.selectTInnovateBannerList(tInnovateBanner);
        ExcelUtil<TInnovateBanner> util = new ExcelUtil<TInnovateBanner>(TInnovateBanner.class);
        util.exportExcel(response, list, "创新链数据");
    }

    /**
     * 获取创新链详细信息
     */
    @PreAuthorize("@ss.hasPermi('banner:banner:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tInnovateBannerService.selectTInnovateBannerById(id));
    }

    /**
     * 新增创新链
     */
    @PreAuthorize("@ss.hasPermi('banner:banner:add')")
    @Log(title = "创新链", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TInnovateBanner tInnovateBanner)
    {
        return toAjax(tInnovateBannerService.insertTInnovateBanner(tInnovateBanner));
    }

    /**
     * 修改创新链
     */
    @PreAuthorize("@ss.hasPermi('banner:banner:edit')")
    @Log(title = "创新链", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TInnovateBanner tInnovateBanner)
    {
        return toAjax(tInnovateBannerService.updateTInnovateBanner(tInnovateBanner));
    }

    /**
     * 删除创新链
     */
    @PreAuthorize("@ss.hasPermi('banner:banner:remove')")
    @Log(title = "创新链", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tInnovateBannerService.deleteTInnovateBannerByIds(ids));
    }
}
